/**
 * Yolema.com Inc.
 * Copyright (c) 2011-2012 All Rights Reserved.
 */
package org.grayrabbit.pay.facade.exception;

import org.grayrabbit.pay.facade.enums.ErrorCodeEnum;

/**
 * 接口返回结果信息
 *  
 * @author wy
 * @version $Id: PayClientException.java, v 0.1 2012-6-5 上午11:08:45 wy Exp $
 */
public class PayClientException extends RuntimeException {

    /** serialVersionUID */
    private static final long serialVersionUID = 2941304670735309736L;

    /** 异常结果码 */
    private String            errorCode;

    /**异常提示信息*/
    private String            errorMsg;

    public PayClientException() {
        super();
    }

    /**
     * 
     * @param errorCodeEnum   异常结果码
     */
    public PayClientException(ErrorCodeEnum errorCodeEnum) {
        super(errorCodeEnum.getMsg());
        this.errorCode = errorCodeEnum.name();
        this.errorMsg = errorCodeEnum.getMsg();
    }

    /**
     * @param cause      异常原因
     */
    public PayClientException(Throwable cause) {
        super(cause);
    }

    @Override
    public String toString() {
        String s = getClass().getName();
        String message = getLocalizedMessage();
        return (message!=null&&message.trim().length()>0) ? (s + ": " + message) : (s + ": " + errorCode
                                                                           + errorMsg + "。");
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorCode() {
        return errorCode;
    }

}
